<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">

        <ui:define name="content">

            <h:form>
                <p:panel toggleable="true" id="batchCreateCG" header="Create a new batch of completed goods">
                    <h:panelGrid columns="3">
                        <h:outputLabel value="Product" for="productCG" />
                        <h:selectOneMenu id="productCG" value="#{batchEntityController.selected.product}" title="Product" >
                            <f:selectItems value="#{completedGoodsEntityController.itemsAvailableSelectOne}"/>
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for= "productCG"/>

                        <h:outputLabel value="Please enter number of cases in batch: " for="quantityCG" />
                        <p:inputText id="quantityCG" value="#{batchEntityController.selected.quantity}" title="Quantity" required="true" requiredMessage="Quantity is missing" />
                        <h:message styleClass="errorMsg" for= "quantityCG"/>

                        <h:outputLabel value="Please enter expiry date for batch: " for="CGBatchExpiry" />
                        <p:calendar mindate="#{batchEntityController.currentDate}" showOn="button" id="CGBatchExpiry" value="#{batchEntityController.selected.expiryDate}" title="Expiry Date" required="true" requiredMessage="Expiry date is missing" />
                        <h:message styleClass="errorMsg" for= "CGBatchExpiry"/>

                    </h:panelGrid>
                </p:panel>
                <br/>
                <p:commandButton onclick="confirmation.show()" value="Next" />
            </h:form>
            <h:form>
                <p:confirmDialog message="Do you wish to fulfil planned reservations first?"  
                                 showEffect="bounce" hideEffect="explode"  
                                 header="None" severity="alert" widgetVar="confirmation">  

                    <p:commandButton ajax="false" value="Yes" oncomplete="confirmation.hide()" action="#{batchEntityController.createCGRedirectToPlannedReserve}"/>  
                    <p:commandButton ajax="false" value="No" oncomplete="confirmation.hide()" action="#{batchEntityController.createCG}" />   

                </p:confirmDialog>  
            </h:form>
            <br />
            <h:form>
                <p:panel toggleable="true" id="batchCreateRM" header="Create a new batch of raw materials">
                    <h:panelGrid columns="3">


                        <h:outputLabel value="Raw Material" for="productRM" />
                        <h:selectOneMenu id="productRM" value="#{batchEntityController.selected.product}" title="Product" >
                            <f:selectItems value="#{rawMaterialEntityController.itemsAvailableSelectOne}"/>
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for= "productRM"/>

                        <h:outputLabel value="Please enter number of KGs in batch: " for="quantityRM" />
                        <p:inputText id="quantityRM" value="#{batchEntityController.selected.quantity}" title="Quantity" required="true" requiredMessage="Quantity is missing" />
                        <h:message styleClass="errorMsg" for= "quantityRM"/>

                        <h:outputLabel value="Please enter expiry date for batch: " for="RMBatchExpiry" />
                        <p:calendar mindate="#{batchEntityController.currentDate}" showOn="button" id="RMBatchExpiry" value="#{batchEntityController.selected.expiryDate}" title="Expiry Date" required="true" requiredMessage="Expiry date is missing" />
                        <h:message styleClass="errorMsg" for= "RMBatchExpiry"/>

                        <h:outputLabel value="Please select purchase order #: " for="rmPurchaseOrder" />
                        <h:selectOneMenu required="true" id="rmPurchaseOrder" value="#{batchEntityController.rawMaterialPurchaseOrderEntity}" title="Raw">
                            <f:selectItems value="#{rawMaterialPurchaseOrderEntityController.unfulfilledRMPurchaseOrdersAvailableSelectOne}"/>
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for= "rmPurchaseOrder"/>
                    </h:panelGrid>

                </p:panel>
                <br/>
                <p:commandButton ajax="false" value="Next" action="#{batchEntityController.createRM}"/>


            </h:form>
        </ui:define>
    </ui:composition>

</html>
